<?php

class RelayAction extends Action{
    //注册成功后显示的页面
    public function first(){
        $this->display();
    }
    
    //显示选择关注类别
    public function sort(){
        $db = M('sort');
        $sort = $db->select();
        $this->assign('st',$sort);
        $this->display();
    }
    //异步过来添加关注类别
    public function addsort(){
        $num = $_POST['num'];
        $num = rtrim($num,'-');
        $numarr = explode('-', $num);
        $db = M('user_sort');
        $stop = true;
        foreach($numarr as $v){
            $data = array('sid'=>$v,'uid'=>$_SESSION['uid']);
            if($db->add($data)){
                $stop = true;
            }else{
                $stop = false;break;
            }
        }
        if($stop){
            echo json_encode(array('num'=>1));
        }else{
            echo json_encode(array('num'=>0));
        }
    }
}

?>
